﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FimetContoDeposito.BLL.Objects;
using GrayParrot.Web.Formly;

namespace FimetContoDeposito.BLL.Metadata
{
    public class MovimentoMetadata
    {
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptionsAttribute(Label = "Id Cliente",
            Placeholder = "",
            Required = false,
            MinLength = 1,
            MaxLength = 100)]
        public string IDCliente { get; set; }

        [FormFieldAttribute(Type = FormFieldTypes.Select)]
        [SelectTemplateOptions(Label = "Articolo",
                               Placeholder = "Indicare l'articolo...",
                               Required = true,
                               Callback = "/api/AnagraficaArticoli/LoadArticoliByCustomer",
                               ForceLoad = true, DependsBy = "IDCliente")]
        public Guid Articolo { get; set; }

        [FormFieldAttribute(Type = FormFieldTypes.Number)]
        [NumericTemplateOptions(Label = "Quantità", Placeholder = "Quantità...", Required = true, Disabled = false)]
        public decimal Quantita { get; set; }
    }

    public class MovimentiExMetadata
    {
        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptionsAttribute(Label = "Num. DDT",
            Placeholder = "Indicare il numero di DDT",
            Required = true,
            MinLength = 1,
            MaxLength = 50)]
        public string NumeroDdt { get; set; }

        [FormFieldAttribute(Type = FormFieldTypes.DateTimepicker)]
        [DateTimeTemplateOptions(Label = "Data DDT",
                                 Placeholder = "Indicare la data del documento DDT...",
                                 Required = true,
                                 RenderingMode = DateTimeRenderingModes.DropDown)]
        public DateTime DataDdt { get; set; }

        [FormFieldAttribute(Type = FormFieldTypes.Input)]
        [TextTemplateOptionsAttribute(Label = "Num. Documento",
            Placeholder = "Indicare il numero di documento",
            Required = true,
            MinLength = 1,
            MaxLength = 50)]
        public string NumeroDocumento { get; set; }

        [FormFieldAttribute(Type = FormFieldTypes.Select)]
        [SelectTemplateOptions(Label = "Cliente",
                               Placeholder = "Indicare il Cliente a cui fa capo il movimento di conto deposito...",
                               Required = true,
                               Callback = "/api/Common/LoadCustomers", ForceLoad = true)]
        public Guid Customer { get; set; }

        [FormFieldAttribute(Type = FormFieldTypes.RepeatSection)]
        [RepeatingSectionTemplateOptions(Label = "Articoli",
                               Placeholder = "Indicare la lista di articoli che fanno parte del DDT...",
                               Required = true, 
                               Fields = "Prenotata, Articolo, Quantita",
                               DrawDirection=DrawDirections.Row)]
        public List<MovimentoDetailBag> Details { get; set; }

    }
}
